package com.drools.drools.chapter6;

import com.drools.drools.model.Person;
import org.junit.Test;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;

/**
 * Created with IntelliJ IDEA.
 * User: mishuai
 * Date: 2019-04-26
 * Time: 22:21
 * Des:
 */
public class testNoloop {

    @Test
    public void test(){
       // StatelessKieSession statelessKieSession=this.getKieSessionByStatelessKieSessionName("no-loop-rules");
       // statelessKieSession.execute(new Person(5));
       KieServices kieServices=KieServices.get();
       KieContainer kieContainer=kieServices.newKieClasspathContainer();
       //StatelessKieSession statelessKieSession=kieContainer.newStatelessKieSession("no-loop-rules");
       //statelessKieSession.execute(new Person(5));
        KieSession kieSession=kieContainer.newKieSession("no-loop-rules");
        FactHandle factHandle=kieSession.insert(new Person(5));
        String str=factHandle.toExternalForm();
        System.out.println(str);
        int count=kieSession.fireAllRules();
        kieSession.update(factHandle,new Person(7));
        kieSession.fireAllRules();
        kieSession.dispose();
    }
}
